<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="bis.*" %>
<%@ include file="GlobalVar.jsp" %>
<% request.setCharacterEncoding("utf-8");%>
<% response.setContentType("text/html;charset=utf-8");%>
<html>
    <head><title>TitleShoppingCart</title>
        <link href="CSS/style1.css" rel="stylesheet">
    </head><body>
        <table width="100%" border="0">
            <tr>
                <td><center>
                        <table width="750" border="0" bgcolor="#FFFFFF">
                            <tr>
                                <td colspan="2" valign="top"><jsp:include page="banner.jsp"/></td>
                            </tr>
                            <tr>
                            <td>&nbsp;</td> </tr>
                            <jsp:useBean id="ebook" scope="page" class="bis.FLBook" />
                            <c:if test="${param.Add!=null}">
                                <jsp:setProperty name="ebook" property="id" value="${param.Add}" />
                            </c:if>
                            <c:forEach var="current" items="${ebook.dateByid}">
                                <c:choose>
                                    <c:when test="${current==null}">
                                        <p>书号"${param.bookId}"在数据库中不存在</p>
                                        <strong><a href="<%=request.getContextPath()%>/bookstore.jsp">继续购物</a></strong>
                                    </c:when>
                                    <c:otherwise>
                                        <jsp:setProperty name="cart" property="add1" value="${param.Add}"/>
                                        <jsp:setProperty name="cart" property="add2" value="${current}"/>
                                    </c:otherwise>
                                </c:choose>
                            </c:forEach>
                            <%
        String bookId = request.getParameter("Remove");
        if (bookId != null) {
            cart.setremove(bookId);
                            %>

                            <%}
        if (request.getParameter("Clear") != null) {
            cart.isclear();
        }%>
                            <tr>
                                <td width="73%" valign="top">
                                    <% // Print a summary of the shopping cart
        int num = cart.getNumberOfItems();
        if (num > 0) {
                                    %>
                                    <table width="100%" height="272"  border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td width="97%" height="220" valign="top">
                                                <table width="100%" height="126"  border="0" cellpadding="0" cellspacing="0">

                                                    <tr>
                                                        <td valign="top">

                                                            <table width="100%" height="59"  border="0" cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td width="86%" height="59" class="tableBorder_B"><img src="Images/ico_cart.gif" width="176" height="70"></td>
                                                                </tr>
                                                            </table>
                                                            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td>
                                                                        <table width="100%" height="48" border="1" align="center" cellpadding="0" cellspacing="0">
                                                                            <tr align="center" valign="middle" bgcolor="#CCCCCC">
                                                                                <td height="27" >编号</td>
                                                                                <td height="27" >书号</td>
                                                                                <td >书名</td>
                                                                                <td height="27">单价</td>
                                                                                <td height="27" >数量</td>
                                                                                <td height="27">金额</td>
                                                                                <td>删除</td>
                                                                            </tr>
                                                                            <%int ii = 0;
                                        Iterator i = cart.getItems().iterator();
                                        while (i.hasNext()) {
                                            FLShoppingCartItem item = (FLShoppingCartItem) i.next();
                                            FLBook pbook = (FLBook) item.getItem();

                                            ii++;
                                                                            %>

                                                                            <tr align="center" valign="middle">
                                                                                <td width="32" height="27"><%=ii%></td>
                                                                                <td width="109" height="27"><%=pbook.getBm()%></td>
                                                                                <td width="199" height="27"><%=pbook.getMc()%></td>
                                                                                <td width="59" height="27">￥<%=pbook.getPrice()%></td>
                                                                                <td width="51" height="27"><%=item.getQuantity()%> </td>
                                                                                <td width="65" height="27">￥<%=(pbook.getPrice() * item.getQuantity())%></td>
                                                                                <td width="34"><a href="<%=request.getContextPath()%>/cartalog.jsp?Remove=<%=pbook.getBm()%>"><img src="Images/del.gif" width="16" height="16"></a></td>
                                                                            <%}%> </tr>
                                                                        </table>

                                                                        <table width="100%" height="52" border="0" align="center" cellpadding="0" cellspacing="0">
                                                                            <tr align="center" valign="middle">
                                                                                <td height="10">&nbsp;		</td>
                                                                                <td width="24%" height="10" colspan="-3" align="left">&nbsp;</td>
                                                                            </tr>
                                                                            <tr align="center" valign="middle">
                                                                                <td height="21" class="tableBorder_B1">&nbsp;</td>
                                                                                <td height="21" colspan="-3" align="left" class="tableBorder_B1"><br><br>合计总金额：￥<%=cart.getTotal()%></td>
                                                                            </tr>
                                                                            <tr align="center" valign="middle">
                                                                                <td height="21" colspan="2"> <a href="<%=request.getContextPath()%>/bookstore.jsp">继续购物</a> |<a href="<%=request.getContextPath()%>/cashier.jsp">去收银台结账</a> |<a href="<%=request.getContextPath()%>/cartalog.jsp?Clear=clear">清空购物车</a></td>
                                                                            </tr>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                        </table></td>
                                                    </tr>
                                                </table>
                                            </td>
                                            <td width="3%" valign="top">&nbsp;</td>
                                        </tr>
                                    </table>
                                    <%} else {%>

                                    <table width="100%"  border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td height="70" colspan="2" class="tableBorder_B"><img src="Images/ico_cart.gif" width="176" height="70"></td>
                                        </tr>
                                        <tr>
                                            <td height="24" colspan="2" align="center">&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td width="48%" height="38" align="right" class="word_orange">您的购物车为空！</td>
                                            <td width="52%" rowspan="3" align="right" valign="bottom"><img src="Images/cart.gif" width="150" height="186"></td>
                                        </tr>
                                        <tr>
                                            <td height="57" align="right"><input name="Button" type="button" class="btn_grey" value="我要购书！" onClick="window.location.href='bookstore.jsp'"></td>
                                        </tr>
                                        <tr>
                                            <td height="72" align="right">&nbsp;</td>
                                        </tr>
                                    </table>
                                    <%        }
                                    %>
                                </td>
                            </tr>
                            <tr><td height="16"><jsp:include page="copyright.jsp"/></td>
                            </tr>
                        </table>
                </center></td>
            </tr>
        </table>
    </body>
</html>
